package com.dd.census.controller;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.dd.census.entity.SysPosition;
import com.dd.census.service.SysPositionService;
import com.dd.census.tools.resopnse.ResultResponse;
import com.dd.census.tools.resopnse.emums.ResultStatus;

@RestController
@RequestMapping(value = "census/sysPosition")
public class SysPositionController {

	private static final Logger logger = LoggerFactory.getLogger(SysPositionController.class);

	@Autowired
	private SysPositionService sysPositionService;

	@RequestMapping("getProvices")
	public ResultResponse<Object> getProvices(@RequestBody SysPosition sysPosition, HttpServletRequest request) {
		try {

			return ResultResponse.buildSuccess(sysPositionService.getProvices(sysPosition));

		} catch (Exception e) {
			// 系统异常
			logger.error("Internal Server Error", e);
			return ResultResponse.buildFailure(ResultStatus.FATAL_ERROR);
		}
	}
	
	
	@RequestMapping("getAllPosition")
	public ResultResponse<Object> getAllPosition(@RequestBody SysPosition sysPosition, HttpServletRequest request) {
		try {

			return ResultResponse.buildSuccess(sysPositionService.getAllPosition(sysPosition));

		} catch (Exception e) {
			// 系统异常
			logger.error("Internal Server Error", e);
			return ResultResponse.buildFailure(ResultStatus.FATAL_ERROR);
		}
	}


}
